package com.thxy.jxgl.mubiaoka.servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.thxy.jxgl.filter.ToCh;
import com.thxy.jxgl.javaBean.khjsff;
import com.thxy.jxgl.javaBean.khmbz;
import com.thxy.jxgl.mubiaoka.manager.JsffManager;
import com.thxy.jxgl.mubiaoka.manager.MubiaozhiManager;

/**
 * Servlet implementation class JsffServlet
 */
public class JsffServlet extends HttpServlet {
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String method = request.getParameter("method") == null?"":request.getParameter("method");
		request.setCharacterEncoding("gbk");
        if("addjsff".equals(method))
        {
            khjsff ff=(khjsff)request.getSession().getAttribute("jsff");
            request.getSession().removeAttribute("jsff");
            String js_id=ff.getJs_id();
            String js_method=ToCh.toChinese(ff.getJs_method());
            String js_type=ff.getJs_type();
            boolean ins=JsffManager.getInstance().addJsff(js_id, js_method,js_type);
        }else if ("delejsff".equals(method)) {
			String no=request.getParameter("jsffno");
			JsffManager.getInstance().deleJsff(no);
		}
		else if ("editjsff".equals(method)) {
			String ffno=request.getParameter("jsffno");
			String ffmethod=request.getParameter("js_method").toString();
			String fftype=request.getParameter("js_type").toString();
			boolean upd=JsffManager.getInstance().updateJsff(ffmethod,fftype, ffno);
		}
		List jsffList=new ArrayList();
		jsffList=JsffManager.getInstance().getJsff();
		request.getSession().setAttribute("jsffList", jsffList);
		request.getRequestDispatcher("/mbkgl/jsff.jsp").forward(request, response);

		}
	
}
